c****HP    first line
c     program mire(para)
c****SG    first line
      program mire
      character *140 para
      character *140  mess
      character imar(2048*2048)
      character imag(2048*2048)
      character imab(2048*2048)
      integer sizex,sizey
      logical redr,greenr,bluer
      common/images/imar,imag,imab
C
      print*,"external program example: duplication"
c**** SG external parameter
      call getarg(1,para)
c
      call sphinx_get_para
     *(sizex,sizey,redr,greenr,bluer,para,mess)
      print*,"image size:",sizex,sizey
      print*,"input banks:",redr,greenr,bluer
      print*,"message zone:",mess(1:30)
      call sphinx_read(para,imar,imag,imab)
      is=sizex*sizey
      if(bluer.and..not.greenr)then
      do i =1,is
      imag(i)=imab(i)
      enddo
      endif
      if(bluer.and..not.redr)then
      do i =1,is
      imar(i)=imab(i)
      enddo
      endif
      if(greenr.and..not.bluer)then
      do i =1,is
      imab(i)=imag(i)
      enddo
      endif
      if(greenr.and..not.redr)then
      do i =1,is
      imar(i)=imag(i)
      enddo
      endif
      if(redr.and..not.greenr)then
      do i =1,is
      imag(i)=imar(i)
      enddo
      endif
      if(redr.and..not.bluer)then
      do i =1,is
      imab(i)=imar(i)
      enddo
      endif
      call sphinx_write(para,imar,imag,imab)
      stop
      end
